package cn.outsourcing.supermarket.converter.customer;

import cn.outsourcing.supermarket.bo.OrdersDataBO;
import cn.outsourcing.supermarket.common.utils.DataUtils;
import cn.outsourcing.supermarket.converter.BackstageOrderConverter;
import cn.outsourcing.supermarket.converter.transform.BooleanToIntegerTransform;
import cn.outsourcing.supermarket.converter.transform.OrderStatusTextTransform;
import cn.outsourcing.supermarket.vo.backstage.BackstageOrdersInfoVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @author gzkemays
 * @since 2021/11/2 22:32
 */
public class BackstageOrderConverterImpl implements BackstageOrderConverter {
  @Override
  public BackstageOrdersInfoVO converterToBoGetVo(OrdersDataBO bos) {
    if (bos == null) {
      return null;
    }
    BackstageOrdersInfoVO ordersInfoVO = new BackstageOrdersInfoVO();

    ordersInfoVO.setAddTime(DataUtils.getTimestampAllData(bos.getAddTime()));
    ordersInfoVO.setId(bos.getId());
    ordersInfoVO.setOrderSn(bos.getOrderSn());
    ordersInfoVO.setUserId(bos.getUserId());
    ordersInfoVO.setOrderStatus(bos.getOrderStatus());
    ordersInfoVO.setOfflinePay(BooleanToIntegerTransform.booleanToInteger(bos.getOfflinePay()));
    ordersInfoVO.setShippingStatus(BooleanToIntegerTransform.booleanToInteger(bos.getShippingStatus()));
    ordersInfoVO.setPrintStatus(BooleanToIntegerTransform.booleanToInteger(bos.getPrintStatus()));
    ordersInfoVO.setPayStatus(BooleanToIntegerTransform.booleanToInteger(bos.getPayStatus()));
    ordersInfoVO.setConsignee(bos.getConsignee());
    ordersInfoVO.setCountry(bos.getCountry());
    ordersInfoVO.setProvince(bos.getProvince());
    ordersInfoVO.setCity(bos.getCity());
    ordersInfoVO.setDistrict(bos.getDistrict());
    ordersInfoVO.setAddress(bos.getAddress());
    ordersInfoVO.setPrintInfo(bos.getPrintInfo());
    ordersInfoVO.setMobile(bos.getMobile());
    ordersInfoVO.setPostscript(bos.getPostscript());
    ordersInfoVO.setAdminMemo(bos.getAdminMemo());
    ordersInfoVO.setShippingFee(bos.getShippingFee());
    ordersInfoVO.setPayName(bos.getPayName());
    ordersInfoVO.setPayId(bos.getPayId());
    ordersInfoVO.setChangePrice(bos.getChangePrice());
    ordersInfoVO.setActualPrice(bos.getActualPrice());
    ordersInfoVO.setOrderPrice(bos.getOrderPrice());
    ordersInfoVO.setGoodsPrice(bos.getGoodsPrice());
    ordersInfoVO.setPayTime(DataUtils.getTimestampAllData(bos.getPayTime()));
    ordersInfoVO.setShippingTime(DataUtils.getTimestampAllData(bos.getShippingTime()));
    ordersInfoVO.setConfirmTime(DataUtils.getTimestampAllData(bos.getConfirmTime()));
    ordersInfoVO.setDealdoneTime(DataUtils.getTimestampAllData(bos.getDealdoneTime()));
    ordersInfoVO.setFreightPrice(bos.getFreightPrice());
    ordersInfoVO.setExpressValue(bos.getExpressValue());
    ordersInfoVO.setRemark(bos.getRemark());
    ordersInfoVO.setOrderType(bos.getOrderType());
    ordersInfoVO.setIsDelete(bos.getIsDelete());
    ordersInfoVO.setOrderStatusText(OrderStatusTextTransform.transform(bos.getOrderStatus()));
    return ordersInfoVO;
  }

  @Override
  public List<BackstageOrdersInfoVO> converterToBoListGetVoList(List<OrdersDataBO> bos) {
    if (bos == null) {
      return null;
    }
    List<BackstageOrdersInfoVO> list = new ArrayList<BackstageOrdersInfoVO>(bos.size());
    for (OrdersDataBO ordersDataBO : bos) {
      list.add(converterToBoGetVo(ordersDataBO));
    }
    return list;
  }
}
